﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ForumsBrowser
{
    /// <summary>
    /// Interaction logic for TestWindow.xaml
    /// </summary>
    public partial class TestWindow : Window
    {
        public TestWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(TestWindow_Loaded);
        }

        void TestWindow_Loaded(object sender, RoutedEventArgs e)
        {
            PrintLogicalTree(this);
        }

        

public void PrintLogicalTree(DependencyObject obj1)
{
    // Recursive callfor each visual child
    for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj1); i++)
    {
        if (obj1 is TextBox)
        {
            ((TextBox)obj1).IsEnabled = false;
        }

        DependencyObject child = VisualTreeHelper.GetChild(obj1, i);
        
        PrintLogicalTree(child);
    }
}
    }
}
